package com.ycj.aop;


import lombok.extern.java.Log;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;

@Aspect
@Component
@Log
public class NotVeryUsefulAspect {
    @Pointcut("execution(* hello(..))") // the pointcut expression
    private void anyOldTransfer() {
    } // the pointcut signature

    @Before("anyOldTransfer()")
    public void doAccessCheck() {
        // ...
        log.info("before");
    }

    @AfterReturning("anyOldTransfer()")
    public void afterReturning() {
        // ...
        log.info("afterReturning");
    }

    @After("anyOldTransfer()")
    public void after() {
        // ...
        log.info("after");
    }

    @AfterThrowing(pointcut = "anyOldTransfer()", throwing = "ex")
    public void afterThrowing(IllegalAccessException ex) {
        // ...
        log.info("afterThrowing");
    }

    @Around("anyOldTransfer()")
    public Object around(ProceedingJoinPoint pjp) throws Throwable {
        // ...
        log.info("around befor");
        // start stopwatch
        Object retVal = pjp.proceed();
        log.info("around after");
        // stop stopwatch
        return retVal;
    }
}

